package shuangzu.top.zzurla.activities;

import android.app.Fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import org.w3c.dom.Text;
import shuangzu.top.zzurla.R;

public class userinfo_fragment extends Fragment {

    private ImageView headpic;
    private TextView stu_name;
    private EditText stu_birth;
    private EditText stu_nation;
    private EditText stu_phone;
    private EditText stu_room;
    private EditText stu_college;
    private EditText stu_major;
    private EditText lab_id;
    private EditText stu_email;
    private EditText stu_sex;
    private TextView stu_username;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.userinfo_fragment,container,false);

        return view;
    }


    @Override
    public void onStart()
    {
        super.onStart();
        SharedPreferences pref= PreferenceManager.getDefaultSharedPreferences(getActivity());
        stu_name.setText(pref.getString("stu_name",""));
        stu_birth.setText(pref.getString("stu_birth",""));
        stu_nation.setText(pref.getString("stu_nation",""));
        stu_phone.setText(pref.getString("stu_phone",""));
        stu_room.setText(pref.getString("stu_room",""));
        stu_college.setText(pref.getString("stu_college",""));
        stu_major.setText(pref.getString("stu_major",""));
        lab_id.setText(pref.getString("lab_name",""));
        stu_email.setText(pref.getString("stu_email",""));
        stu_sex.setText(pref.getString("stu_sex",""));
        stu_username.setText(pref.getString("username",""));
        String imgpath=pref.getString("stu_img","");
        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(getActivity()));
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageForEmptyUri(R.drawable.ic_luncher_dabai)
                .showImageOnFail(R.drawable.ic_luncher_dabai)
                .showImageOnLoading(R.drawable.ic_luncher_dabai)
                .build();
        ImageLoader.getInstance().displayImage(imgpath,headpic,options);

    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        headpic=(ImageView)getActivity().findViewById(R.id.userinfo_pic);
        stu_name=(TextView)getActivity().findViewById(R.id.ui_stu_name);
        stu_birth=(EditText)getActivity().findViewById(R.id.stu_birth);
        stu_nation=(EditText)getActivity().findViewById(R.id.stu_nation);
        stu_phone=(EditText)getActivity().findViewById(R.id.stu_phone);
        stu_room=(EditText)getActivity().findViewById(R.id.stu_room);
        stu_college=(EditText)getActivity().findViewById(R.id.stu_college);
        stu_major=(EditText)getActivity().findViewById(R.id.stu_major);
        lab_id=(EditText)getActivity().findViewById(R.id.lab_id);
        stu_email=(EditText)getActivity().findViewById(R.id.stu_email);
        stu_sex=(EditText)getActivity().findViewById(R.id.stu_sex);
        stu_username=(TextView)getActivity().findViewById(R.id.ui_username);



    }
}
